package com.android.myapplication.third.greendao;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.greendao.gen.DaoSession;
import com.greendao.gen.TeacherBeanDao;
import com.greendao.gen.StudentBean2Dao;

import java.util.List;

@Entity(nameInDb="student2")
public class StudentBean2 {
    @Id
    Long id;

    @Property
    @NotNull
    String name;

    @Property
    Integer sex;

    @Property
    Integer age;


    @Property
    String className;

    long fk_teacher_id;

    @ToOne(joinProperty = "fk_teacher_id")
    private TeacherBean teacherBean;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 142670051)
    private transient StudentBean2Dao myDao;

    @Generated(hash = 1751256915)
    public StudentBean2(Long id, @NotNull String name, Integer sex, Integer age,
            String className, long fk_teacher_id) {
        this.id = id;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.className = className;
        this.fk_teacher_id = fk_teacher_id;
    }

    @Generated(hash = 1286799106)
    public StudentBean2() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSex() {
        return this.sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return this.age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getClassName() {
        return this.className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public long getFk_teacher_id() {
        return this.fk_teacher_id;
    }

    public void setFk_teacher_id(long fk_teacher_id) {
        this.fk_teacher_id = fk_teacher_id;
    }

    @Generated(hash = 1501167222)
    private transient Long teacherBean__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 994855589)
    public TeacherBean getTeacherBean() {
        long __key = this.fk_teacher_id;
        if (teacherBean__resolvedKey == null
                || !teacherBean__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            TeacherBeanDao targetDao = daoSession.getTeacherBeanDao();
            TeacherBean teacherBeanNew = targetDao.load(__key);
            synchronized (this) {
                teacherBean = teacherBeanNew;
                teacherBean__resolvedKey = __key;
            }
        }
        return teacherBean;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 915697320)
    public void setTeacherBean(@NotNull TeacherBean teacherBean) {
        if (teacherBean == null) {
            throw new DaoException(
                    "To-one property 'fk_teacher_id' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.teacherBean = teacherBean;
            fk_teacher_id = teacherBean.getId();
            teacherBean__resolvedKey = fk_teacher_id;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 654174281)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getStudentBean2Dao() : null;
    }
    public String toString(){

        return "学生名称: "+name;
    }

}
